<?php
class keu_list_jurnal_model extends MY_Model {
	var $model = 'keu_list_jurnal';
	
	
	function GetJSON()
	{
		$ls_sql	= "	SELECT	TRANS.ID_DOK , OFC.NAMA_KANTOR, TO_CHAR(TRANS.TGL_TRANSAKSI,'DD/MM/YYYY') TGL_TRANSAKSI, 
							TRANS.KETERANGAN, TRANS.ID_COA,  TRANS.KD_VALUTA,
							TP.NAMA_TIPE_JURNAL
					FROM	KEU_TRANSAKSI TRANS, SW_KANTOR OFC, KEU_TIPE_JURNAL TP
					WHERE	
							TP.KD_TIPE_JURNAL = TRANS.KD_TIPE_JURNAL AND
							TRANS.KD_TIPE_JURNAL LIKE '%".post('kd_tipe_jurnal')."%'  AND
							OFC.KD_KANTOR = TRANS.KD_KANTOR  AND
							NVL(STATUS_VERIFIKASI,'N')='Y' AND
							TRANS.TGL_TRANSAKSI BETWEEN 
							TO_DATE('".date_format3(post('date_from'), 'YYYY-MM-DD')."','YYYY-MM-DD') AND 
							TO_DATE('".date_format3(post('date_to'), 'YYYY-MM-DD')."','YYYY-MM-DD') AND					
							(
								OFC.NAMA_KANTOR LIKE '%".post('keyword')."%' OR
								TRANS.KD_VALUTA LIKE '%".post('keyword')."%' OR
								TRANS.KETERANGAN LIKE '%".post('keyword')."%' OR
								TRANS.ID_DOK LIKE '%".post('keyword')."%'
							)
					ORDER BY ".(post('sort')=='' ? 'ID_DOK' : post('sort'))." ".(post('order')=='' ? 'ASC' : post('order'));
					
		return json_encode( $this->paging($ls_sql) );
	}
	
	
	function GetDetailJSON($as_doc='')
	{
		$ls_sql	= "	SELECT	*
					FROM	KEU_TRANSAKSI_DETAIL
					WHERE ID_DOK = '".$as_doc."'";
		$result	= $this->db->query($ls_sql);			
		return json_encode( $result->row_array() );
	}
}
?>